package tech.aistar.prj.service.impl;

import org.apache.ibatis.session.SqlSession;
import tech.aistar.prj.mapper.UserMapper;
import tech.aistar.prj.model.pojo.User;
import tech.aistar.prj.service.IUserService;
import tech.aistar.prj.util.MybatisUtil;

import java.sql.SQLException;

public class UserServiceImpl implements IUserService {
    @Override
    public User findByUsername(String username) {
        User user = null;
        SqlSession sqlSession = null;
        try {
            sqlSession = MybatisUtil.getSession();
            UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
            user = userMapper.getByUsername(username);

        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            MybatisUtil.close(sqlSession);
        }
        return user;
    }

}
